<template>
	<uni-section title="订单列表" type="line">
		<uni-card :title="item.hospitalName"
				  v-for="(item,index) in orderList" :key="index" 
				  
				  >
			<view class="uni-body">
				医院地址:{{item.address}}
			</view>
			<view >
				就诊信息:{{item.department1Name}} > {{item.department2Name}}
			</view>
			<view >
				就诊医生:{{item.doctorName}}
			</view>
			<view >
				就诊时间:{{item.year}}/{{item.month}}/{{item.day}} {{scheduleTime[item.scheduleCode]}}
			</view>
			<view >
				排号:{{item.rank}}
			</view>
			<view>
				<view v-if="item.year>=time.year&&item.month>=time.month&&item.day>time.day">
					状态:<uni-tag text="待就诊" type="success" />
				</view>
				<view v-else-if="item.year<=time.year&&item.month<=time.month&&item.day<time.day">
					状态:<uni-tag text="已就诊" type="warning" />
				</view>
				<view v-else>
					状态:<uni-tag text="就诊中" type="primary" />
				</view>
			
			</view>
		</uni-card>
	</uni-section>
</template>

<script lang="ts" setup>
import { getCurrentUserOrder } from '@/api/orders';
import { onLoad } from '@dcloudio/uni-app';
import { ref, unref } from 'vue';
	const orderList = ref<any>({})
	const scheduleTime = ['全天','上午','下午','晚上']
	const time = {
		year:new Date().getFullYear(),
		month:new Date().getMonth() +1,
		day:new Date().getDate()
	}
	const handleOrderList = async()=>{
		orderList.value = await getCurrentUserOrder()
	}
	onLoad(()=>{
		handleOrderList()
		console.log('time',time);
	})
	
	
	
	
</script>

<style>

</style>
